
pkgname=e2fsprogs
pkgver=1.44.2
pkgrel=1
pkgdesc="Ext2/3/4 filesystem utilities"
arch=('x86_64')
license=('GPL' 'LGPL' 'MIT')
url="http://e2fsprogs.sourceforge.net"
groups=('base')
depends=('sh' 'util-linux')
makedepends=('bc')
source=("https://www.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v${pkgver}/${pkgname}-${pkgver}.tar.xz"
        'MIT-LICENSE')
backup=('etc/mke2fs.conf')
sha256sums=('8324cf0b6e81805a741d94087b00e99f7e16144f1ee5a413709a1fa6948b126c'
            'cc45386c1d71f438ad648fd7971e49e3074ad9dbacf9dd3a5b4cb61fd294ecbb')

build() {
  cd ${pkgname}-${pkgver}

  ./configure --prefix=/usr \
      --with-root-prefix="" \
      --libdir=/usr/lib \
      --enable-elf-shlibs \
      --disable-fsck \
      --disable-uuidd \
      --disable-libuuid \
      --disable-libblkid \
      --enable-htree \
      --enable-blkid-debug \
      --enable-verbose-makecmds \
      --enable-e2initrd-helper \
      --enable-quota

  make
}

package() {
  cd ${pkgname}-${pkgver}
  make -j1 DESTDIR="${pkgdir}" install install-libs

  sed -i -e 's|^AWK=.*|AWK=awk|' ${pkgdir}/usr/bin/compile_et
  
  # remove references to build directory
  sed -i -e 's|^SS_DIR=.*|SS_DIR="/usr/share/ss"|' ${pkgdir}/usr/bin/mk_cmds
  sed -i -e 's|^ET_DIR=.*|ET_DIR="/usr/share/et"|' ${pkgdir}/usr/bin/compile_et
  # remove 64bit ref, new for e2fsprogs 1.43
  # possible breaks calamares installs https://github.com/calamares/calamares/wiki/Deployment-Practices
  sed -i -e 's|huge_file,flex_bg,64bit,dir_nlink|huge_file,flex_bg,dir_nlink|' ${pkgdir}/etc/mke2fs.conf
  
  # addition for zulucrypt
  ln -sf /sbin/mkfs.ext4 ${pkgdir}/usr/bin/mkfs.ext4

  install -Dm644 ${srcdir}/MIT-LICENSE ${pkgdir}/usr/share/licenses/${pkgname}/MIT-LICENSE
}
